﻿/**
 * $HeadURL: http://smartcollector.googlecode.com/svn/branches/Srcs/SmartCollector.WebUI/SmartCollector.WebUI/Helpers/Heppers.cs $
 * $Author: chithanh12@gmail.com $
 * $Date: 2011-04-20 20:08:17 +0000 (Wed, 20 Apr 2011) $
 * $Rev: 95 $
 **/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;
using System.IO;

namespace SmartCollector.WebUI.Helpers
{
    public static class Heppers
    {
        public static Bitmap crop(string userimage, int Width, int Height)
        {
            Image OriginalImage = Image.FromFile(userimage);
            Bitmap newimage = null;

            newimage = new Bitmap(OriginalImage, Width, Height);

            return newimage;
        }
        /// <summary>
        /// Hàm cắt chuổi 
        /// </summary>
        /// <param name="str">chuổi cần cắt</param>
        /// <param name="Lenght">chiều dài cần cắt</param>
        /// <returns>chuổi đã cắt</returns>
        public static string CropString(string str,int Lenght)
        {
            string details = string.Empty ;
            if (str.Length>Lenght)
            {
                int subLenght = str.IndexOf(" ", Lenght);
                if (subLenght > 0)
                {
                    details = str.Substring(0, subLenght).Trim();
                }
                else
                {
                    details = str.Trim();
                }
            }
            else
            {
                details = str.Trim();
            }
            return details;
        }
    }
}